package cn.edu.zafu.bigdata.cccnnn.workone;

public abstract class Shape {
    public abstract double area();
    public abstract double perimeter();

    // final方法，用于打印形状的类型、面积和周长
    public final void display() {
        System.out.println("Type: " + this.getClass().getSimpleName());//返回方法的名字
        System.out.println("Area: " + area());
        System.out.println("Perimeter: " + perimeter());
    }
}

class Circle extends Shape {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    public double area() {
        return Math.PI * radius * radius;
    }

    public double perimeter() {
        return 2 * Math.PI * radius;
    }
}

class Rectangle extends Shape {
    private double length;
    private double width;

    public Rectangle(double a, double b) {
        this.length = length;
        this.width = width;
    }


    public double area() {
        return length * width;
    }


    public double perimeter() {
        return 2 * (length + width);
    }
}
